package lzc.demo.spring.eureka.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import lzc.demo.spring.eureka.entity.User;

@RestController
public class UserController {
	@Autowired
	DiscoveryClient discoveryClient;
	
	@GetMapping("/getUser/{id}")
	public User getUser(@PathVariable Integer id) {
		String services = "Services: " + discoveryClient.getServices();
		System.out.println(services);
		
		User user = new User();
		
		user.setId(id);
		user.setName("test");
		
		return user;
	}
	
	@PostMapping("/getUserInfo")
	public User getUserInfo(@RequestBody User user) {
		return user;
	}
	
}
